package net.tobby.acm.controller;

import java.io.Serializable;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.tobby.acm.db.mysql.HouseService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA. User: tangb Date: 4/20/12 Time: 3:19 PM To change this template use File | Settings | File Templates.
 */

@Controller
@RequestMapping("/test")
public class MysqlController {

	protected Logger log = LoggerFactory.getLogger(this.getClass().getName());

	@Resource
	private HouseService<Serializable> houseService;

	@RequestMapping(value = "/testMySQL")
	public ModelAndView testMySQL(HttpServletRequest request, HttpServletResponse response) throws Exception {

		log.info("[ testDerby ] houseService: " + houseService);

//		Map<String, Object> paraMap = new HashMap<String, Object>();
//		List<House> allHouses = houseService.findAllHouse(paraMap);
//		if (allHouses != null) {
//			for (House house : allHouses) {
//				log.info("" + house.getHouseNumber());
//			}
//		}

		return new ModelAndView("welcome");

	}
	
	@RequestMapping(value = "/testMySQLHibernate")
	public ModelAndView testMySQLHibernate(HttpServletRequest request, HttpServletResponse response) throws Exception {

		log.info("[ testDerby ] houseService: " + houseService);

//		Map<String, Object> paraMap = new HashMap<String, Object>();
//		List<House> allHouses = houseService.findAllHouse(paraMap);
//		if (allHouses != null) {
//			for (House house : allHouses) {
//				log.info("" + house.getHouseNumber());
//			}
//		}

		return new ModelAndView("welcome");

	}

}
